<?php
class keu_pemb_pendaftaran_anggota_model extends MY_Model {
	var $model = 'keu_pemb_pendaftaran_anggota';
	
	function GetImportJSON()
	{
		$ls_sql	= "	SELECT	SESSID, INDEX_NO, FIELD1, FIELD2, FIELD3, FIELD4, FIELD5,FIELD6,FIELD7,FIELD8,FIELD9,FIELD10,FIELD11,FIELD12
					FROM	KEU_IMPORT_TAGIHAN
					WHERE 1=1
					ORDER BY ".(post('sort')=='' ? 'INDEX_NO' : post('sort'))." ".(post('order')=='' ? 'ASC' : post('order'));
		
		return json_encode( $this->paging($ls_sql) );
	}
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT TA.NO_URUT, TA.ID_ANGGOTA, AG.PERSON_ID,
						   TO_CHAR (TA.TGL_TAGIHAN, 'DD/MM/YYYY') tgl_tagihan,
						   P.FULL_NAME NAMA_ANGGOTA,
						   TA.BULAN_TAGIHAN,
						   TA.SIMP_WAJIB,
						   TA.SIMP_POKOK,
						   TA.SIMP_SUKARELA,
						   NVL(TA.BIAYA_KARTU,0) BIAYA_KARTU,
						   TA.TOTAL_TAGIHAN
					  FROM SIS_TAGIHAN_ANGGOTA TA INNER JOIN SIS_ANGGOTA AG
						   ON AG.ID_ANGGOTA = TA.ID_ANGGOTA
						   INNER JOIN SW_PERSON P ON AG.PERSON_ID = P.PERSON_ID
					 WHERE NVL (TA.ST_LUNAS, '0') = '0' AND
							TA.NO_URUT=1 AND
							TA.TGL_TAGIHAN BETWEEN 
							TO_DATE('".date_format3(post('date_from'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND 
							TO_DATE('".date_format3(post('date_to'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND					
							(
								UPPER(TA.NO_URUT) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(AG.PERSON_ID) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(TA.ID_ANGGOTA) LIKE UPPER('%".post('keyword')."%') OR
								UPPER(P.FULL_NAME)	LIKE UPPER('%".post('keyword')."%')							
							)
					ORDER BY ".(post('sort')=='' ? 'TA.ID_ANGGOTA' : post('sort'))." ".(post('order')=='' ? 'ASC' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
	
	function Add($arr_data){
		$this->db->insert('KEU_TRANS_KAS_BANK', $arr_data);
	}
	
	function GetSingleView($as_anggota, $ai_no_urut)
	{
		$ls_sql	= "	SELECT TA.NO_URUT, TA.ID_ANGGOTA, AG.PERSON_ID,
						   TO_CHAR (TA.TGL_TAGIHAN, 'DD/MM/YYYY') tgl_tagihan,
						   P.FULL_NAME NAMA_ANGGOTA,
						   TA.BULAN_TAGIHAN,
						   TA.SIMP_WAJIB,
						   TA.SIMP_POKOK,
						   TA.SIMP_SUKARELA,
						   NVL(TA.BIAYA_KARTU,0) BIAYA_KARTU,
						   TA.TOTAL_TAGIHAN
					  FROM SIS_TAGIHAN_ANGGOTA TA INNER JOIN SIS_ANGGOTA AG
						   ON AG.ID_ANGGOTA = TA.ID_ANGGOTA
						   INNER JOIN SW_PERSON P ON AG.PERSON_ID = P.PERSON_ID
					 WHERE NVL (TA.ST_LUNAS, '0') = '0' AND
							TA.ID_ANGGOTA = '".$as_anggota."' AND
							TA.NO_URUT='".$ai_no_urut."'";
					
							
		$result	= $this->db->query($ls_sql);
		
		if($result->num_rows() == 1){
			return $result->row_array();
		}else{
			return NULL;
		}
	}
	
	
}
?>